package model

type Article struct {
	Id         int    `json:"id" form:"id" gorm:"column:id"`
	Oriented   int8   `json:"oriented" form:"oriented" gorm:"column:oriented"`
	CateId     int    `json:"cate_id" form:"cate_id" gorm:"column:cate_id" binding:"required"`
	Title      string `json:"title" form:"title" gorm:"column:title" binding:"required,max=150"`
	Desc       string `json:"desc" form:"desc" gorm:"column:desc"`
	Pic        string `json:"pic" form:"pic" gorm:"column:pic" binding:"required,max=255"`
	Content    string `json:"content" form:"content" gorm:"column:content"`
	CreateTime int64  `json:"create_time" form:"create_time" gorm:"column:create_time"`
	Status     int8   `json:"status" form:"status" gorm:"column:status"`
	AdminId    int    `json:"admin_id" form:"admin_id" gorm:"column:admin_id"`
}

type ArticleApi struct {
	Id         int         `json:"id" form:"id" gorm:"column:id"`
	CateId     int         `json:"cate_id" form:"cate_id" gorm:"column:cate_id"`
	Title      string      `json:"title" form:"title" gorm:"column:title"`
	Pic        string      `json:"pic" form:"pic" gorm:"column:pic"`
	CreateTime int64       `json:"create_time" form:"create_time" gorm:"column:create_time"`
	Status     int8        `json:"status" form:"status" gorm:"column:status"`
	AdminId    int         `json:"admin_id" form:"admin_id" gorm:"column:admin_id"`
	Cate       ArticleCate `json:"cate" gorm:"foreignKey:CateId"`
}

func (a Article) TableName() string {
	return "mp_article"
}

func (a ArticleApi) TableName() string {
	return "mp_article"
}

type ArticleOriented struct {
	Id           int    `json:"id" form:"id" gorm:"column:id"`
	OrientedName string `json:"oriented_name" form:"oriented_name" gorm:"column:oriented_name"`
}

func (t ArticleOriented) TableName() string {
	return "mp_article_oriented"
}
